import request from '@/utils/request';
import { AxiosPromise } from 'axios';
const BIZ_BASE_URL = "biz/data/error";
/**
 * 错误日志查询参数
 */
export interface ErrorLogQuery {
  keywords?: string;
  type?: string;
  level?: string;
  status?: string;
  startTime?: string;
  endTime?: string;
  cur: number;
  limit: number;
}

/**
 * 错误日志对象
 */
export interface ErrorLog {
  id: string;
  title: string;
  type: string;
  level: string;
  status: string;
  startTime: string;
  stopTime?: string;
  content: string;
}

/**
 * 错误日志分页对象
 */
export interface ErrorLogPage {
  totalRow: ErrorLog[];
  total: number;
  size: number;
  current: number;
}

/**
 * 错误日志接口
 */
export default {
  /**
   * 获取错误日志分页列表
   */
  getErrorLogPage(queryParams: ErrorLogQuery) {
    return request<any, PageResult<any[]>>({
      url: `${BIZ_BASE_URL}/pages`,
      method: "get",
      params: queryParams,
    });
  },

  /**
   * 标记关闭错误日志
   */
  closeErrorLog(id: string): AxiosPromise<any> {
    return request({
      url: `/biz/data/error/${id}/close`,
      method: 'post'
    });
  }
};
